/**
 * Created by Administrator on 2018/1/13.
 */
/**
 * Created by Administrator on 2017/12/2.
 */
define(function(require, exports, module) {
    var $=require('zepto');
    api=require('api');
    cn=require('conment');
    cook=require('cookie');
    module.exports = {
        int:{
            is:false,
            word:'',
            free:cn.getQueryString('free'),
        },
        seach_stock:function () {
            const _this=this;
            cn.Ajax(api.seach,{
                keyword:_this.int.word
            },function(d){
                $('#quickQuery_list').empty();
                var arr=new Array(),list=d.list;
                // console.log(_this.int.free)
                $.each(list,function(i,l,array){
                    if(_this.int.free){
                        arr.push('<li class="liCode" data-code="'+l.code+'" data-free="true"> <a class="ang_code" href="javascript:void(0)">');///view/free_market.html?code='+l.code+'&free='+_this.int.free+'
                    }else{
                        arr.push('<li class="liCode" data-code="'+l.code+'" data-free="false"> <a class="ang_code" href="javascript:void(0)">');///view/astock_market.html?code='+l.code+'
                    }
                        arr.push('<span class="quickQuery_title">'+l.name+'<i class=""></i></span> ' +
                        '<span class="isShow"></span><span class="txt_last">'+l.code+'</span> </a> </li>');
                });
                $('#quickQuery_list').append(arr.join(''));
                $('#quickQuery_list li').on('click',function () {
                    var code=$(this).data('code');
                    cn.setItem('market_url',window.location.href)
                    if(_this.int.free==10){
                        window.location.href='/view/free_market.html?code='+code+'&free='+_this.int.free
                    }else{
                        window.location.href='/view/astock_market.html?code='+code
                    }
                })

            },'post')
        },
        onKeyup:function () {
            const _this=this;
            $('.seach_code').on('input propertychange',function () {
                _this.int.word=$.trim($(this).val());
                _this.seach_stock();
            })
        },
        init:function () {
            const _this=this;
            _this.onKeyup();
        }

    }
});